home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1996 February
/
EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso
/
earcd
/
util1
/
xpkilzr.lha
/
xpkILZR
/
source
/
eilzr.copia
< prev
next >
Wrap
Text File
|
1994-02-19
|
3KB
|
127 lines
/**-----------------------------------------------------------------------
* Bloque de includes, por fin me ocupan menos de una pagina de
* impresisn, lo que hay que hacer para tener todos los prototipos..
*
**/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <fcntl.h>
#define NO_SUB_PRAGMAS
#include <libraries/xpksub.h>
#include "ilzr.h"
/**-----------------------------------------------------------------------
* Prototipos para todas estas paridas necesarias para compilar.
*
**/
long __saveds __asm XpksUnpackChunk( REG __a0 XPARAMS* xpar )
{
/* variables para input - output */
register CHARS *inpb;
register CHARS *outb;
register CHARS *bumpcode;
register CHARS *outbstart;
signed long outbsize;
register ULONG temp;
register signed char shift;
UBYTE bitcount;
ULONG matchpos;
ULONG matchlen;
inpb = xpar->InBuf;
outb = xpar->OutBuf;
shift = 0;
outbstart= outb;
outbsize = *((unsigned short *)inpb);
inpb += 2; /* short leido */
bitcount = INIT_BIT_BUMP;
bumpcode = &outb[ 1<<INIT_BIT_BUMP ];
if( outbsize > xpar->OutBufLen )
return( XPKERR_SMALLBUF );
xpar->OutBufLen = outbsize;
while( outbsize > 0 )
{
if( *inpb & (0x80>>shift) )
{
shift++;
if( shift > 7 )
{
shift=0;
inpb++;
}
temp = ( ((ULONG *)inpb)[0]);
temp = ( temp>>(24-shift) );
*outb= temp;
outb++;
inpb++;
outbsize--;
}
else
{
shift++;
if( shift > 7 )
{
shift=0;
inpb++;
}
if( bumpcode < outb )
{
bitcount++;
bumpcode = &outbstart[ 1<<bitcount ];
}
temp = ( ((ULONG *)inpb)[0]);
temp = temp >> ( 32 - bitcount - shift );
matchpos = temp & ((1<<bitcount)-1);
shift += bitcount; /* ALWAYS bitccount >= 8 */
shift -=8;
inpb++;
if( shift > 7 )
{
shift-=8;
inpb++;
}
temp = ( ((ULONG *)inpb)[0]);
temp = temp >> ( 32 - BITS_LOOKAHEAD - shift );
matchlen = temp & ((1<<BITS_LOOKAHEAD)-1);
shift += BITS_LOOKAHEAD;
if( shift > 7 )
{
shift-=8;
inpb++;
}
matchlen += MIN_MATCH;
memcpy( outb , &outbstart[ matchpos ] , (size_t)matchlen );
outb += matchlen;
outbsize -= matchlen;
}
}
return( 0 );
}
/************************** End of ILZR.C *************************/